package com.pipidan.blog.controller;

import cn.afterturn.easypoi.excel.ExcelImportUtil;
import cn.afterturn.easypoi.excel.entity.ImportParams;
import com.pipidan.blog.entity.TestDto;
import com.pipidan.blog.service.TestRedisService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;
import java.io.IOException;
import java.nio.channels.MulticastChannel;
import java.util.List;

/**
 * @Author: runda
 * @CreateTime: 2022-12-05 20:49
 * @Description:
 */
@Controller
@RequestMapping("/test")
public class TestRedisController {

    @Autowired
    private TestRedisService testService;

    @GetMapping("/t/{id}")
    public void testRedis(){
        testService.findAll();
    }
    @PostMapping("/excel")
    public void importExcel(@RequestParam("file") MultipartFile file) throws Exception {
//        ExcelImportUtil.importExcel(file.getInputStream(), BrandInfo.class, new ImportParams());
        String name = file.getName();

        List<Object> objects = ExcelImportUtil.importExcel(file.getInputStream(), TestDto.class, new ImportParams());
        System.out.println("objects = " + objects);
    }

}
